import request from '@/utils/request'

/**
 * 登录
 * @param data
 * @returns {*}
 */
export const login = data => {
  const { username, password } = data
  const params = new URLSearchParams()
  params.append('username', username)
  params.append('password', password)
  return request({
    url: '/login',
    method: 'POST',
    params,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
    }
  })
}

/**
 * 获取用户信息
 */
export const getUserInfo = () => {
  return request({
    url: '/user/profile'
  })
}

export const changePassword = (data) => {
  return request({
    url: '/user/changePass',
    method: 'POST',
    params: data
  })
}

export const getWxPermission = (data) => {
  return request({
    url: '/user/wxPermission',
    method: 'POST',
    params: data
  })
}

export const updatePermissionUsers = (data) => {
  return request({
    url: '/user/updatePermissionUsers',
    method: 'POST',
    params: data
  })
}
